<template>
  <div class="index">
    <van-swipe :autoplay="3000">
      <van-swipe-item
        v-for="(item, index) in imglist"
        :key="index"
      >
        <a :href="item.content"><img :src="item.url" /></a>
      </van-swipe-item>
    </van-swipe>
   <ul>
    <li>
     <img src="../../assets/images/z02.png" width="40" height="40px" /><a>图文任务<p>开启后将会自动分派任务单</p></a>

      <a v-if="onAccept" class="button" style="background-color:gainsboro" @click="accept('off')" >已开启</a>
      <a v-else class="button" style="background-color:#06CFB2" @click="accept('on')" >开启</a>

    </li>
    </ul>
 </div>
</template>
<script>
import po from "../../assets/images/po.jpg";
import { noticeList,tasklist,getUserInfo,setTaskQueue,delTaskQueue } from "../../api/user";
import { Toast } from "vant";
export default {
  data() {
    return {
      onAccept:false,
      title: "如何赚佣",
      iconnameright: "",
      iconnameleft: "",
      list: [],
      imglist: [
        {
          url: require("../../assets/images/banner1@2x.png"),
          content:"/qrcode"
        },
      ],
      taskList:[],
      listParameter:{
        pageno:1,
        pagesize:30,
        count:0,
      },
      isfull: false,
    };
  },
  methods: {
    accept(act){
      if(act == "on"){

        this.onAccept = true
        setTaskQueue().then(res => {
          localStorage.setItem("task_queue",1);
          Toast(res.message);
        });

      }else if(act == "off"){

        this.onAccept = false
        delTaskQueue().then(res => {

          if(res.status ==200){
            localStorage.setItem("task_queue",0);
            Toast("已取消，下次开启将会重新排队");
          }else{
            this.onAccept = true
            Toast(res.message);
          }
        });

      }
    },

    getBaseInfo(){
      let task_queue = localStorage.getItem('task_queue')

      if( task_queue ==0){
        this.onAccept = false
      }else if( task_queue ==1){
        this.onAccept = true
      }
    },
    // getData() {
    //   noticeList().then(res => {
    //     console.log(res)
    //     this.list = res.data;
    //   });
    // },
  },
  created() {
    this.getBaseInfo();
    // this.getData();
  }
};
</script>

<style lang="scss">
.index {
  width: 100%;
  /*// height: 100%;*/
  background-color: #f1f1f1;
  padding-bottom: 30px;
  /*.tips {*/
    /*.van-swipe__indicators {*/
      /*display: none;*/
    /*}*/
    /*padding-left: 10px;*/
    /*line-height: 40px;*/
    /*height: 40px !important;*/
  /*}*/
   /**/
  .van-swipe {
    width: 100%;
    height: 100px;
    img {
      width: 100%;
    }
    .van-swipe__indicator--active {
      width: 14px;
      height: 5px;
      background: rgba(255, 68, 91, 1);
      border-radius: 3px;
    }
  } 
 ul{
   .price{
     color: red;
     padding-left: 5px;
     font-size: 12px;
   }
 	list-style:none;
 	padding-bottom:15px;
     li{
      height:85px;
      overflow:hidden;
      padding:22px 12px;
      margin:10px 0;
      background:#fff;
      border-radius:4px;
      .button{
        font-size: 12px;
        width: 23%;
        text-align: center;
        height: 36px;
        line-height: 36px;
        margin:3px 0;
        border-radius: 200px;
        background: #fc6e48;
        color:#fff;
       }
      img{
      float:left;
      margin-right:10px;
      }
     a{
      color:#333;
      text-decoration:none;
      font-size:16px;
      font-weight:400;
      line-height:22px;
      width:58%;
 	    float:left;
     p{
        color:#666;
        font-size:13px;
        font-weight:300;
      }
 	  }
 	}
 	}
}
</style>





